var incont=0;
var sounds;

function soundManagerInit(fn)
{
	var assetsPath = "sound/";
	sounds = [
		{id: "back", src: "bgmusic.mp3"},
		{id: "infor", src: "dingg.mp3"},
		{id: "thp", src: "THP.mp3"},
		{id: "die", src: "bang.mp3"},
		{id: "num", src: "countdown.mp3"}
	];
	createjs.Sound.alternateExtensions = ["mp3"];
	createjs.Sound.registerSounds(sounds, assetsPath);
	createjs.Sound.on("fileload", loadHandler);
	function loadHandler(event) {
		incont++;
		if(incont==sounds.length){
			fn();
		}
	}
}


function playSound(id)
{
	for(var i=0;i<sounds.length;i++){
		if(sounds[i].id==id){
			sounds[i].instance=createjs.Sound.play(id);
			sounds[i].instance.loop=500;
			sounds[i].instance.volume = 0.5;
		}
	}
}

function stopSound(id)
{
	for(var i=0;i<sounds.length;i++){
		if(sounds[i].id==id){
			sounds[i].instance.stop();
		}
	}
}